The following sample shows how to cancel a record of Items object. Use this sample as a basis to all business objects of master data type (not documents).
Sub CancelRecord()
Dim RetVal As Long
Dim ErrCode As Long
Dim ErrMsg As String
Dim vItem As SAPbobsCOM.Items
Set vItem = vCmp.GetBusinessObject(oItems)
'Retrieve the record to cancel from the databse
RetVal = vItem.GetByKey("A00023")
If RetVal <> 0 Then
vCmp.GetLastError ErrCode, ErrMsg
MsgBox "Failed to Retrieve the record " & ErrCode & " " & ErrMsg
Exit Sub
End If
'Cancel the record
RetVal = vItem.Cancel
If RetVal <> 0 Then
vCmp.GetLastError ErrCode, ErrMsg
MsgBox "Failed to Cancel the record " & ErrCode & " " & ErrMsg
End If
End Sub